package com.nit.lab.utils;

import javax.servlet.http.HttpSessionListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSession;
/**
 * Created by shen on 2017/11/20.
 */
public class SessionListener implements HttpSessionListener {
    private SessionContext sc = SessionContext.getInstance();


    public void sessionCreated(HttpSessionEvent httpSessionEvent) {
        //System.out.println("新建一个session");
        sc.addSession(httpSessionEvent.getSession());
    }

    public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
        //System.out.println("销毁一个session");
        HttpSession session = httpSessionEvent.getSession();
        sc.delSession(session);
    }
}
